package com.qst.survey.handler;

import com.qst.survey.pojo.Result;
import com.qst.survey.pojo.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Date: 2021/3/16 20:55
 * @Description: 统一 异常 处理类
 */

@ControllerAdvice  //该类是一个增强类
public class BaseExceptionHandler {

    @ExceptionHandler(value = Exception.class)  //所有异常由这个类处理
    @ResponseBody
    public Result error(Exception e) {
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR, "当前系统繁忙，请您稍后重试");
    }
}
